﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class frmMSSQL : Form
    {
        public frmMSSQL()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (!validateUserInput())
            {
                return;
            }
           //do the logic here

        }

        private bool validateUserInput()
        {
            bool isValid = true;
            if (txtServerName.Text.Trim() == string.Empty)
            {
                this.errorProvider1.SetError(txtServerName, "server name cannot be blank");
                isValid = false;
            }
            if (txtDbName.Text.Trim() == string.Empty)
            {
                this.errorProvider1.SetError(txtDbName, "Database name cannot be blank");
                isValid = false;
            }
            if (txtUserID.Text.Trim() == string.Empty)
            {
                this.errorProvider1.SetError(txtUserID, "user ID cannot be blank");
                isValid = false;
            }
            if (txtPwd.Text.Trim() == string.Empty)
            {
                this.errorProvider1.SetError(txtPwd, "password cannot be blank");
                isValid = false;
            }
            return isValid;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            //hid the form
        }

        private void btnTestConnection_Click(object sender, EventArgs e)
        {
            //call isconnected method and display the result to the user
        }
    }
}
